package cate.game.role.show.msg;

import cate.common.table.area.AreaCityRow;
import cate.common.table.area.AreaProvinceRow;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBBlog;
import easy.java.dev.note.NoteField;

@ClientMsg(title = "修改地区 の 请求")
public class ModifyAreaReq implements MsgInput {

    @NoteField("省")
    public int province;

    @NoteField("市")
    public int city;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        AreaProvinceRow provinceRow = game.table.area.province.get(province);
        AreaCityRow cityRow = game.table.area.city.get(city);
        if (provinceRow == null || cityRow == null || cityRow.belongCode != provinceRow.code) {
            game.notice.message(cc.getRole(), "参数不合法");
            return;
        }
        cc.getRole().getBase().province = province;
        cc.getRole().getBase().city = city;
        cc.getRole().sendNow(new ModifyAreaResp(cc.getRole()));
        //game.notice.message(cc.getRole(), "修改成功");
    }


    @Override
    public MsgConfig conf() {
        return MsgIdBBlog.MODIFY_AREA_REQ;
    }
}
